package sharewithus.business.dao.impl;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import sharewithus.business.dao.IUserDAO;
import framelib.dao.AbsDAO;

/**
 * Title:EXDAOImpl
 * Description:test DAO
 * @Create_by:Vince Yu
 * @Create_date:2012-5-4
 * @Last_Edit_By:
 * @Edit_Description
 * @version:partynano 1.0
 * 
 */
@SuppressWarnings("unchecked")
public class UserDAOImpl extends AbsDAO implements IUserDAO {
	private static final Log log = LogFactory.getLog(UserDAOImpl.class);
	
	@SuppressWarnings("unchecked")
	public int saveUser(
			String email,
			String nickname,
			String password,
			Timestamp resTime) {
	    Map<String, Object> param = new HashMap<String, Object>();
	    param.put("email", email);
	    param.put("nickname", nickname);
	    param.put("password", password);
	    param.put("resTime", resTime);
		return Integer.parseInt(this.getSqlMapClientTemplate().insert("saveUser", param).toString());
	}
	
	
	public void saveUserExt(
			int userId,
			int extId,
			String extValue,
			int permission,
			int flag, 
			Timestamp lastUpdateTime) {
		Map<String, Object> param = new HashMap<String, Object>();
	    param.put("userId", userId);
	    param.put("extId", extId);
	    param.put("extValue", extValue);
	    param.put("permission", permission);
	    param.put("flag", flag);
	    param.put("lastUpdateTime", lastUpdateTime);
	    this.getSqlMapClientTemplate().insert("saveUserExt", param);
	}
	
	@SuppressWarnings("unchecked")
	public int updateUser(
			int userId,
			String email,
			String nickname,
			String password,
			String avatar,
			Timestamp resTime) {
	    Map<String, Object> param = new HashMap<String, Object>();
	    param.put("userId", userId);
	    param.put("email", email);
	    param.put("nickname", nickname);
	    param.put("password", password);
	    param.put("avatar", avatar);
	    param.put("resTime", resTime);
		return this.getSqlMapClientTemplate().update("updateUser", param);
	}
	
	@SuppressWarnings("unchecked")
	public void deleteUserExt(
			int userId) {
		Map<String, Object> param = new HashMap<String, Object>();
	    param.put("userId", userId);
		this.getSqlMapClientTemplate().delete("deleteUserExt", param);
	}


	public List getUserExtBy(String var, String type) {
	    // TODO Auto-generated method stub
	    return null;
    }


	public Object getUserBy(String var, String type) {
	    // TODO Auto-generated method stub
	    return null;
    }

}